package com.willie.boot.rabbit.provider;

import com.willie.boot.rabbit.config.RabbitmqConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * <p>
 *
 * </p>
 *
 * @author willie
 * @since 2019/1/31
 */
@Component
public class MyMQProvider {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        String context = "hello rabbit";
        System.out.println("Sender:" + context + LocalDate.now());
        this.rabbitTemplate.convertAndSend("hey", context);
    }

    public void sendDelayMessage() {
        String context = "延迟队列测试";
        System.out.println("Sender:" + context + LocalDate.now());
        this.rabbitTemplate.convertAndSend(RabbitmqConfig.orderFanoutExchange, "", context);
    }
}
